package com.xcity.game.player.operation;

import java.text.MessageFormat;

import com.xcity.db.entity.Player;
import com.xcity.game.common.AbstractConfirmOperation;
import com.xcity.game.common.Cause;
import com.xcity.game.common.MessageConst;
import com.xcity.game.player.PlayerUtils;
import com.xcity.pomelo.push.msg.TipPush;

public class BuyStrengthOperation extends AbstractConfirmOperation {

	private int val;
	private int stone;
	
	public BuyStrengthOperation(Player ref, int val, int stone) {
		super(ref, MessageFormat.format(MessageConst.BUY_STRENGTH_HINT, stone, val));
		this.val = val;
		this.stone = stone;
	}

	@Override
	public void ok(Player player) {
		if (player.costStone(stone, Cause.BUY_STRENGTH)) {
			player.addStrength2(val, Cause.BUY_STRENGTH);
			PlayerUtils.countBuyStrength(player, 1);
		} else {
			player.send(new TipPush(MessageConst.STONE_NOT_ENOUTH));
		}
	}

}
